export class RequestParam {
    /**
     * 名称
     */
    key: string;

    /**
     * 值
     */
    value: string;

    /**
     * 是否必填
     * @type {boolean}
     */
    required = false;

    /**
     * 描述
     */
    description?: string;

    /**
     * urlParam的替换正则表达式
     */
    regex?: RegExp;

    /**
     * 规则（正则表达式）
     */
    rulePattern?: RegExp;

    /**
     * value是否匹配 rulePattern
     */
    match?: boolean;

    /**
     * 是否有效
     */
    available = false;

    public static getEmpty(): RequestParam {
        return <RequestParam>{
            key: '',
            value: '',
            required: false,
            description: '',
            match: true,
            available: false
        };
    }

    public static getDefaultHeaders(): RequestParam[] {
        return <RequestParam[]>[{
            key: 'Content-Type',
            value: 'application/json',
            description: '请求中的媒体类型信息',
            required: true,
            rulePattern: new RegExp('^.+$'),
            match: true
        }, {
            key: 'cache-control',
            value: 'no-cache',
            description: '请求不缓存',
            required: false,
            match: true,
            available: true
        }, RequestParam.getEmpty()];
    }
}
